
struct.o:     file format elf64-littleaarch64


Disassembly of section .text:

0000000000000000 <main>:
	char a3[6];
	char a4[8];
}aaa;

int main()
{
   0:	a9bc7bfd 	stp	x29, x30, [sp, #-64]!
   4:	910003fd 	mov	x29, sp
	char buf[30];
	
	memset(buf, '0', sizeof(buf));
   8:	910063a0 	add	x0, x29, #0x18
   c:	d28003c2 	mov	x2, #0x1e                  	// #30
  10:	52800601 	mov	w1, #0x30                  	// #48
  14:	94000000 	bl	0 <memset>
	strcpy(buf,"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
  18:	910063a2 	add	x2, x29, #0x18
  1c:	90000000 	adrp	x0, 0 <main>
  20:	91000001 	add	x1, x0, #0x0
  24:	aa0203e0 	mov	x0, x2
  28:	a9400c22 	ldp	x2, x3, [x1]
  2c:	a9000c02 	stp	x2, x3, [x0]
  30:	f9400822 	ldr	x2, [x1, #16]
  34:	f9000802 	str	x2, [x0, #16]
  38:	b8417021 	ldur	w1, [x1, #23]
  3c:	b8017001 	stur	w1, [x0, #23]
	
	printf("buf length : %d\n", sizeof(buf));
  40:	90000000 	adrp	x0, 0 <main>
  44:	91000000 	add	x0, x0, #0x0
  48:	d28003c1 	mov	x1, #0x1e                  	// #30
  4c:	94000000 	bl	0 <printf>
	printf("struct length : %d\n", sizeof(struct aaa));
  50:	90000000 	adrp	x0, 0 <main>
  54:	91000000 	add	x0, x0, #0x0
  58:	d2800201 	mov	x1, #0x10                  	// #16
  5c:	94000000 	bl	0 <printf>
	
	aaa *aa;
	aa = (struct aaa*)buf;
  60:	910063a0 	add	x0, x29, #0x18
  64:	f9001fa0 	str	x0, [x29, #56]
	
	// 按照结构里的类型填充各个字段.
	printf("a1 is %d\n", aa->a1);
  68:	f9401fa0 	ldr	x0, [x29, #56]
  6c:	39400000 	ldrb	w0, [x0]
  70:	2a0003e1 	mov	w1, w0
  74:	90000000 	adrp	x0, 0 <main>
  78:	91000000 	add	x0, x0, #0x0
  7c:	94000000 	bl	0 <printf>
	printf("a1 is %c\n", aa->a1);
  80:	f9401fa0 	ldr	x0, [x29, #56]
  84:	39400000 	ldrb	w0, [x0]
  88:	2a0003e1 	mov	w1, w0
  8c:	90000000 	adrp	x0, 0 <main>
  90:	91000000 	add	x0, x0, #0x0
  94:	94000000 	bl	0 <printf>
	//printf("a1 is %s\n", aa->a1);	Segmentation fault. 因为字段是单个字节.	2012/11/1
	
	printf("a2 is %d\n", aa->a2);
  98:	f9401fa0 	ldr	x0, [x29, #56]
  9c:	39400400 	ldrb	w0, [x0, #1]
  a0:	2a0003e1 	mov	w1, w0
  a4:	90000000 	adrp	x0, 0 <main>
  a8:	91000000 	add	x0, x0, #0x0
  ac:	94000000 	bl	0 <printf>
	printf("a2 is %c\n", aa->a2);
  b0:	f9401fa0 	ldr	x0, [x29, #56]
  b4:	39400400 	ldrb	w0, [x0, #1]
  b8:	2a0003e1 	mov	w1, w0
  bc:	90000000 	adrp	x0, 0 <main>
  c0:	91000000 	add	x0, x0, #0x0
  c4:	94000000 	bl	0 <printf>
	//printf("a2 is %s\n", aa->a2);	Segmentation fault	因为字段是单个字节.

	printf("a3 is %s\n", aa->a3);		// why not overflow, xiaozhi? 因为被转换成了指针
  c8:	f9401fa0 	ldr	x0, [x29, #56]
  cc:	91000801 	add	x1, x0, #0x2
  d0:	90000000 	adrp	x0, 0 <main>
  d4:	91000000 	add	x0, x0, #0x0
  d8:	94000000 	bl	0 <printf>
	printf("a4 is %s\n", aa->a4);		// ditto
  dc:	f9401fa0 	ldr	x0, [x29, #56]
  e0:	91002001 	add	x1, x0, #0x8
  e4:	90000000 	adrp	x0, 0 <main>
  e8:	91000000 	add	x0, x0, #0x0
  ec:	94000000 	bl	0 <printf>

	printf("a3 is %.6s\n", aa->a3);
  f0:	f9401fa0 	ldr	x0, [x29, #56]
  f4:	91000801 	add	x1, x0, #0x2
  f8:	90000000 	adrp	x0, 0 <main>
  fc:	91000000 	add	x0, x0, #0x0
 100:	94000000 	bl	0 <printf>
	printf("a4 is %.8s\n", aa->a4);
 104:	f9401fa0 	ldr	x0, [x29, #56]
 108:	91002001 	add	x1, x0, #0x8
 10c:	90000000 	adrp	x0, 0 <main>
 110:	91000000 	add	x0, x0, #0x0
 114:	94000000 	bl	0 <printf>
	
	return 0;
 118:	52800000 	mov	w0, #0x0                   	// #0
}
 11c:	a8c47bfd 	ldp	x29, x30, [sp], #64
 120:	d65f03c0 	ret
